package com.hspedu.poly_.objectpoly_;

/**
 * @Author Stringzhua
 * @Date 2024/3/2 16:56
 * description:
 */
public class PloyObject {
    public static void main(String[] args) {
        //体验对象多态的特点
        //animal 编译类型是Animal  运行类型是Dog
        Animal animal = new Dog();
        //运行时,这时即执行到该行时,animal的编译类型是animal,运行类型是Dog
        //所以此处的cry是Dog的cry
        animal.cry();//Dog cry() 小狗汪汪叫~~~

        //animal的编译类型是animal,运行类型是Cat
        animal = new Cat();
        animal.cry();//Cat cry() 小猫喵喵叫~~
    }
}
